const products = [
    {
        img: "./img/m1.jpg",
        name: "Xiaomi Mi Note 10",
        price: 1999
    },
    {
        img: "./img/m2.png",
        name: "Xiaomi MIX Fold 4",
        price: 9999
    },
    {
        img: "./img/m4.jpg",
        name: "Xiaomi MIX Fold 3",
        price: 6999
    },
    {
        img: "./img/m5.png",
        name: "Xiaomi MIX Filp",
        price: 6499
    },
    {
        img: "./img/m6.png",
        name: "Xiaomi MIX Fold 2",
        price: 6499
    },
    {
        img: "./img/m7.png",
        name: "Xiaomi MIX Filp随身拍",
        price: 8999
    },
    {
        img: "./img/m8.png",
        name: "Xiaomi 15",
        price: 4999
    },
    {
        img: "./img/m9.png",
        name: "Xiaomi 15定制版",
        price: 4999
    },
];


const productElements = products.map(({ img, name, price }) => `
    <div class="item">
        <a href="#">
            <img src="${img}" alt="">
            <p class="item-name">${name}</p>
            <p class="item-price">${price}元</p>
        </a>
    </div>
`).join('');


document.querySelector('.product').innerHTML = productElements;